<?php
/**
 * Created by PhpStorm.
 * User: gaochaolyf
 * Date: 16/5/18
 * Time: 上午11:58
 */

namespace api\Model;

use Think\Model;

class CommentEntityModel extends Model
{
    function __construct() {
        $this->model = M('CommentEntity');
        $this->model1 = M('DiaryResponse');
    }

    public function getCommentList($field = array('*'), $condition = array(), $page = 1, $pergage = 10, $order = 'com_id asc') {
        $data = $this->model->where($condition)->field($field)->page($page, $pergage)->order($order)->select();
        $data = $data ? $data : array();

        return $data;
    }

    public function getOneComment($field = array('*'), $condition = array()) {
        $data = $this->model->where($condition)->field($field)->find();
        $data = $data ? $data : array();

        return $data;
    }
    

    public function addOneComment($param = array()) {
        $insert_id = $this->model->data($param)->add();

        return $insert_id;
    }



    public function updateOneComment($param = array(), $condition = array()) {
        $affected = $this->model->where($condition)->setField($param);

        return $affected;
    }
}